package com.mavenq.fly.business.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

@Service
public class AsyncTaskService {

    @Async
    public List<String> asyncTask() throws InterruptedException {
        System.out.println("asyncTask start ...");
        TimeUnit.SECONDS.sleep(5);
        System.out.println("asyncTask end ...");
        return new ArrayList<>();
    }

    public List<String> syncTask() throws InterruptedException {
        System.out.println("syncTask start ...");
        TimeUnit.SECONDS.sleep(1);
        System.out.println("syncTask end ...");
        return new ArrayList<>();
    }
}
